package org.beetl.sql.core.mapper.internal;


import java.lang.reflect.Method;

import org.beetl.sql.clazz.kit.AutoSQLEnum;
import org.beetl.sql.core.SQLExecutor;
import org.beetl.sql.core.SQLManager;
import org.beetl.sql.mapper.MapperInvoke;

public class TemplateAmi extends MapperInvoke{

	@Override
	public Object call(SQLManager sm, Class entityClass, Method m, Object[] args) {
		// 检查args数组的长度
	    if (args == null) {
	        throw new IllegalArgumentException("args array cannot be null or empty");
	    }

	    // 处理args长度为1的情况
	    if (args.length != 3) {
	    	throw new IllegalArgumentException("args array length must be three");
	    }
	    SQLExecutor script = sm.getScript(sm.getClass(), AutoSQLEnum.SELECT_BY_TEMPLATE);
	    return script.select(entityClass, args[0], ((Integer) args[1]).longValue(), ((Integer) args[2]).longValue());
	}

}
